{include file="common/top" /}
<style>
html{
	background: #ffffff;
}
</style>
<form class="layui-form " action="" style="    background: #fff;">
	<div class="layui-form-item">
		<label class="layui-form-label">退款编号：</label>
		<div class="layui-col-xs4">
			<input type="text" readonly="readonly" name="code" value="{$num}" lay-verify="required" autocomplete="off" class="layui-input">
		</div>
		<label class="layui-form-label">退款时间：</label>
		<div class="layui-col-xs4">
			<input type="text" name="create_time" id="date" lay-verify="datetime" placeholder="yyyy-MM-dd H:i:s" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-col-space10">
		<label class="layui-form-label">*退款账户：</label>
		<div class="layui-col-xs2">
			<select name="op_account_id" lay-verify="required" lay-search="" lay-filter="acc"  autocomplete="off" >
				<option value="">直接选择或搜索选择</option>
				{volist name="acc_list" id='acc'}
					<option value="{$acc.id}" >{$acc.name_id}</option>
				{/volist}
	        </select>
		</div>
		<label class="layui-form-label">端口：</label>
		<div class="layui-col-xs2">
			<input type="text" id="channel" readonly="readonly" autocomplete="off"  class="layui-input">
		</div>
		<label class="layui-form-label">客户：</label>
		<div class="layui-col-xs2">
			<input type="text" id="customer" readonly="readonly" autocomplete="off"  class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-col-space10">
		<label class="layui-form-label">*客户返点：</label>
		<div class="layui-col-xs2">
			<input type="text" name="rebate" lay-verify="required" placeholder="请输入客户返点" autocomplete="off"  class="layui-input">
		</div>
		<label class="layui-form-label">*端口返点：</label>
		<div class="layui-col-xs2">
			<input type="text" name="channel_rebate" lay-verify="required" placeholder="请输入端口返点" autocomplete="off"  class="layui-input">
		</div>
		<label class="layui-form-label">*销售返点</label>
		<div class="layui-col-xs2">
			<input type="text" name="sell_rebates" lay-verify="required" placeholder="请输入销售返点" autocomplete="off"  class="layui-input">
		</div>
	</div>
	<div class="layui-form-item layui-col-space10">
		<label class="layui-form-label">*退款账户币：</label>
		<div class="layui-col-xs4">
			<input type="text" name="currency" lay-verify="required" placeholder="请输入退款账户币" autocomplete="off" class="layui-input">
		</div>
		<label class="layui-form-label">*媒介：</label>
		<div class="layui-col-xs4">
			<select name="media_id" lay-verify="required" lay-search="" lay-filter="channel" lay-verify="required" autocomplete="off" >
				<option value="">直接选择或搜索选择</option>
				{volist name="user_list" id='m'}
					<option value="{$m.id}" >{$m.username}</option>
				{/volist}
	        </select>
		</div>
	</div>
	<div class="layui-form-item">
        <label class="layui-form-label">上传凭证：</label>
        <div class="layui-col-xs4">
            <div class="layui-upload-drag" id="test10">
                  <i class="layui-icon"></i>
                  <p>点击上传，或将文件拖拽到此处</p>
                  <div class="layui-hide" id="uploadDemoView">
                      <hr>
                    <img src="" alt="上传成功后渲染" style="max-width: 196px">
                  </div>
            </div>
        </div>
        
    </div>
	<div class="layui-form-item">
		<label class="layui-form-label">备注：</label>
		<div class="layui-col-xs8">
			<textarea name="note" autocomplete="off" placeholder="请输入详细备注" class="layui-textarea"></textarea>
		</div>
	</div>
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
			<input type="hidden"  name="screenshot_url" value="">
			<input type="hidden"  name="channel_id" value="">
			<input type="hidden"  name="customer_id" value="">
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">提交</button>
		</div>
	</div>
	
</form>
{include file="common/footer" /}
<script>
	var t = new Date().getTime();
	layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var form = layui.form ,layer = layui.layer,laydate = layui.laydate,$ = layui.jquery,upload = layui.upload;
		laydate.render({
			elem: '#date', //指定元素
			type: 'datetime',
			value: new Date(t)
		});
		  //监听提交
        form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('add_acc_refund')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) { 
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					//父页面数据 ，重新加载
					parent.get_acc(data['msg']);
				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			return false;
		});
		//下拉菜单事件 渠道
		form.on('select(acc)', function (data) {
			get_channel(data.value)
		})
		function get_channel(id){
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('get_acc_dianwei')}?t=json",{id:id},function(da){
				layer.closeAll();
					if(da['code'] == 1){
						da = da.data;
						$("input[name=rebate]").val(da.rebate) ;
						$("input[name=channel_rebate]").val(da.channel_rebate) ;
						$("input[name=sell_rebates]").val(da.sell_rebates) ;
						$('#channel').val(da.channel_name);
						$("input[name=channel_id]").val(da.channel_id);
						$("input[name=customer_id]").val(da.customer_id);
						$('#customer').val(da.customer_name);
						form.render();
						
					}else{
						$("input[name=rebate]").val('') ;
						$("input[name=channel_rebate]").val('') ;
						$("input[name=sell_rebates]").val('') ;
						$('#channel').val('');
						$("input[name=channel_id]").val('');
						$("input[name=customer_id]").val('');
						$('#customer').val('');
						form.render("select");
						layer.msg(da['msg'], { icon : 5 });
					}
			})
		}
		//拖拽上传
		upload.render({
		    elem: '#test10'
		    ,url: '{:url("Upload/index")}' //改成您自己的上传接口
		    ,exts: 'jpg|png|jpeg|gif'
	    	,choose: function(obj){
	    		layer.load(1, { shade : [ 0.5, '#676a6c' ] });
	    	}
		    ,done: function(res){
		    	layer.closeAll();
		    	if(res.code == 0){
		    		layer.msg('上传成功');
				    layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.data);
				    $("input[name=screenshot_url]").val(res.data);
		    	}else{
		    		layer.msg(res.msg);
		    	}
		      
		      //console.log(res)
		    }
		});
    });
	
</script>
